package com.zy.swagger.converter;

import com.zy.swagger.dto.SysUserDTO;
import com.zy.swagger.entity.sys.SysUser;
import com.zy.swagger.vo.SysUserVO;
import org.springframework.beans.BeanUtils;

/**
 * 系统用户表(表sys_user)数据实体转换辅助类
 *
 * @author ZY
 * @date 2021-04-24 00:08:43
 */
public class SysUserConverter {

    /**
     * 私有化构造器
     */
    private SysUserConverter() {
    }

    /**
     * 实体类转DTO
     *
     * @param entity 实体类
     * @return 转换后的对象
     */
    public static SysUserDTO covertToDTO(SysUser entity) {
        SysUserDTO dto = new SysUserDTO();
        BeanUtils.copyProperties(entity, dto);
        return dto;
    }

    /**
     * 实体类转VO
     *
     * @param entity 实体类
     * @return 转换后的对象
     */
    public static SysUserVO convertToVO(SysUser entity) {
        SysUserVO vo = new SysUserVO();
        BeanUtils.copyProperties(entity, vo);
        return vo;
    }

    /**
     * DTO转实体类
     *
     * @param dto 参数对象
     * @return 转换后的实体类对象
     */
    public static SysUser convertFromDTO(SysUserDTO dto) {
        SysUser entity = new SysUser();
        BeanUtils.copyProperties(dto, entity);
        return entity;
    }

    /**
     * VO转实体类
     *
     * @param vo 参数对象
     * @return 转换后的实体类对象
     */
    public static SysUser convertFromVO(SysUserVO vo) {
        SysUser entity = new SysUser();
        BeanUtils.copyProperties(vo, entity);
        return entity;
    }

}